//
//  LZFVedioView.m
//  LZFBuDieJie
//
//  Created by 梁梓烽 on 16/7/2.
//  Copyright © 2016年 liangzifeng. All rights reserved.
//

#import "LZFVedioView.h"
#import "UIImageView+Download.h"
#import "LZFTopicItem.h"


@interface LZFVedioView ()
@property (weak, nonatomic) IBOutlet UIImageView *backImageView;
@property (weak, nonatomic) IBOutlet UILabel *playCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *vedioTimeLabel;


@end
@implementation LZFVedioView


-(void)setTopicItem:(LZFTopicItem *)topicItem
{
    _topicItem=topicItem;
    //背景图片
//    [self.backImageView sd_setImageWithURL:[NSURL URLWithString:topicItem.image1] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"]];
    
    //根据网络状态去下载原图或者是缩略图
        [self.backImageView lzf_setImageWithOriginalImageURL:self.topicItem.large_image thumbnailImageURL:self.topicItem.small_image placeholderImage:[UIImage imageNamed:@"defaultUserIcon"]];
    
    //播放量
    self.playCountLabel.text=[self playCountTextWith:topicItem.playcount];
    
    //播放时间
    
    self.vedioTimeLabel.text=[self voiceTimeTextWith:topicItem.videotime];
 
}


//播放量数据处理
-(NSString *)playCountTextWith:(NSInteger)count
{
    if (count>10000.0) {
        return [NSString stringWithFormat:@"%0.2f万播放",count/10000.0];
    }
    else if(count>1000.0)
    {
        return [NSString stringWithFormat:@"%ld播放",count];
    }
    else
    {
        return @"";
    }
}

//播放时间处理
-(NSString *)voiceTimeTextWith:(NSInteger)vediotime
{
    NSInteger hour = vediotime/60;
    NSInteger min = vediotime%60;
    return [NSString stringWithFormat:@"%02ld:%ld",hour,min];;
}

@end
